﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;

    [ScriptType("SP.UserCustomActionCollection", ServerTypeId="{70d1cb2d-d304-4d96-9b54-74b3f400fa28}")]
    public class UserCustomActionCollection : ClientObjectCollection<UserCustomAction>
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public UserCustomActionCollection(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        [Remote]
        public UserCustomAction Add()
        {
            UserCustomAction action = new UserCustomAction(base.Context, new ObjectPathMethod(base.Context, base.Path, "Add", null));
            base.AddChild(action);
            return action;
        }

        [Remote]
        public void Clear()
        {
            ClientAction query = new ClientActionInvokeMethod(this, "Clear", null);
            base.Context.AddQuery(query);
        }

        [Remote]
        public UserCustomAction GetById(Guid userCustomActionId)
        {
            Dictionary<Guid, UserCustomAction> dictionary;
            object obj2;
            if (base.ObjectData.MethodReturnObjects.TryGetValue("GetById", out obj2))
            {
                dictionary = (Dictionary<Guid, UserCustomAction>) obj2;
            }
            else
            {
                dictionary = new Dictionary<Guid, UserCustomAction>();
                base.ObjectData.MethodReturnObjects["GetById"] = dictionary;
            }
            UserCustomAction action = null;
            if (!dictionary.TryGetValue(userCustomActionId, out action))
            {
                action = new UserCustomAction(base.Context, new ObjectPathMethod(base.Context, base.Path, "GetById", new object[] { userCustomActionId }));
                dictionary[userCustomActionId] = action;
            }
            return action;
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (flag)
            {
                return flag;
            }
            return flag;
        }
    }
}

